﻿#include <QCoreApplication>
#include "http_client.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    HttpClient* ptr = new HttpClient;
#if 0
    ptr->send_get_req("http://tbkt.txhlwxx.com/upload/main/file");
#else
    string str_boundary = "xwkjautoupload";
    string postdata = "";
    ptr->add_post_key_value(postdata, "appsecret", "3908c33da5ff3954b7ceed64acbeb59c", str_boundary);
    ptr->add_post_key_value(postdata, "cm_code", "50003", str_boundary);
    ptr->add_post_key_value(postdata, "file_time", "2021-09-18 17:12:30", str_boundary);
    ptr->add_post_key_value(postdata, "file_md5", "5eb63bbbe01eeed093cb22bb8f5acdc3", str_boundary);
    ptr->add_post_file(postdata, "file", "/mnt/hd0/video/Course_2021_09_16_15_30_1920x1080_4000_30_Mov/Video1.mp4", str_boundary);

    //设置协议头
    string url = "http://tbkt.txhlwxx.com/upload/main/file";
    string headers = ptr->get_protocal_head("multipart/form-data", 0, str_boundary);
    ptr->send_post_req(url, headers, (char*)postdata.c_str());
#endif
    return a.exec();
}
